<?php
class TopAction extends Action {
	public function _initialize() {
		if ($_GET ['top_session'] != "") {
			$_SESSION ['top_session'] = $_GET ['top_session'];
			//$_SESSION['seller_nick'] = 
		}
		$this->_top_session = $_SESSION ['top_session'];
		if (empty ( $_SESSION ['top_session'] )) {
			$this->error( '需要登录确认你的身份', U('Auth/login')  );
		} else {
			$this->getseller();
		}
	}
	
	
	public function getseller() {
		if( $_SESSION['seller_nick'] ) return ;
		$params = array (
				'method' => 'taobao.user.seller.get',
				'session' => $this->_top_session,
				'timestamp' => date ( 'Y-m-d H:i:s' ),
				'format' => TAO_RETURN_FORMAT,
				'app_key' => TAO_APPKEY,
				'v' => '2.0',
				'sign_method' => 'md5',
	
				'fields' => 'user_id,nick,sex,avatar'
		);
	
		$tc = new TopClient ();
	
		$seller = $tc->getResult ( $params );
		if ($seller) {
			A ( 'Auth' )->userInit ( $seller );
		}
	}
}